package com.lsq.controller;

import com.lsq.common.AjaxResult;
import com.lsq.common.RequestMapping;
import com.lsq.entity.Auctionuser;
import com.lsq.service.AuctionUserService;
import com.lsq.service.impl.AuctionUserServiceImpl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @version 1.0
 * @author:罗苏琴
 * @Date 2024/12/13 下午7:59
 */
@RequestMapping("/auth")
public class LoginServlet {
    AuctionUserService auctionUserService=new AuctionUserServiceImpl();
   @RequestMapping("/login")
    public AjaxResult login(HttpServletRequest request, HttpServletResponse response){
       String username=request.getParameter("username");
       String userPassword=request.getParameter("userPassword");
       System.out.println("username:"+username);
       System.out.println("userPassword:"+userPassword);
       Auctionuser auctionuser =auctionUserService.Login(username,userPassword);
      AjaxResult ajaxResult=new AjaxResult();
      if(auctionuser!=null){
          ajaxResult.setCode(200);
          ajaxResult.setResult(auctionUserService);
      }else {
          ajaxResult.setCode(500);
          ajaxResult.setMsg("登录失败，账号或密码错误");
      }
      return  ajaxResult;
   }
}
